#
# @lc app=leetcode.cn id=145 lang=python3
#
# [145] 二叉树的后序遍历
#

# @lc code=start
# Definition for a binary tree node.
# class TreeNode:
#     def __init__(self, val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    outList = []
    def postorderTraversal(self, root: TreeNode) -> List[int]:    
    
        Solution.outList = []
        if root != None:
            self.midOrder(root)

        return Solution.outList    
        
    def midOrder(self,treeNode):

        if treeNode.left != None:
            self.midOrder(treeNode.left)
        
        if treeNode.right != None:
            self.midOrder(treeNode.right)
        
        Solution.outList.append(treeNode.val)        
# @lc code=end

